package com.example.element.activity;

import androidx.recyclerview.widget.LinearLayoutManager;

import com.alibaba.android.arouter.facade.annotation.Route;
import com.example.common.adapter.MenuAdapter;
import com.example.common.base.AbsActivity;
import com.example.common.model.MenuBean;
import com.example.element.module.constraint.ConstraintLayoutActivity;
import com.example.element.R;
import com.example.element.Utils.RouterControl;
import com.example.element.databinding.ActElemetnMainBinding;
import com.example.element.module.content_provider.ContactsActivity;
import com.example.element.module.jetpack.viewmodel.ViewModelActivity;
import com.example.element.module.jetpack.workmanager.WorkerActivity;
import com.example.element.module.media.MediaActivity;
import com.example.element.module.netWork.HttpUrlConnectionActivity;
import com.example.element.module.netWork.OkHttpActivity;
import com.example.element.module.notification.NotificationActivity;
import com.example.element.module.photo.CameraAlbumActivity;
import com.example.element.module.service.ServiceActivity;

import java.util.ArrayList;
import java.util.List;

@Route(path = "/element/menu")
public class MenuActivity extends AbsActivity<ActElemetnMainBinding> {

    @Override
    protected int getLayoutId() {
        return R.layout.act_elemetn_main;
    }

    @Override
    protected void main() {
        init();
        initAdapter();
    }

    private void init() {
        setTitle("SystemElement");
    }

    @Override
    protected void initListener() {

    }

    private void initAdapter() {
        List<MenuBean> data = new ArrayList<>();
        data.add(new MenuBean("lifecycle", 0));
        data.add(new MenuBean("Android events ", 0));
        data.add(new MenuBean("IPC 通信", 0));
        data.add(new MenuBean("Permission Home", 0));
        data.add(new MenuBean("Content provider-get the Contacts", 0));
        data.add(new MenuBean("Notification", 0));
        data.add(new MenuBean("Camera album", 0));
        data.add(new MenuBean("Media Audio", 0));
        data.add(new MenuBean("Service ", 0));
        data.add(new MenuBean("Constraint layout ", 0));
        data.add(new MenuBean("NetWork HttpUrlConnection ", 0));
        data.add(new MenuBean("NetWork OkHttp Xml ", 0));
        data.add(new MenuBean("Material toolbar", 0));
        data.add(new MenuBean("JetPack ViewModel", 0));
        data.add(new MenuBean("JetPack WorkManger", 0));
        MenuAdapter adapter = new MenuAdapter(data);
        adapter.setOnItemClickListener((adapter1, view, position) -> {
            switch (position) {
                case 0:
                    RouterControl.jumpLifecycleHome();
                    break;
                case 1:
                    RouterControl.jumpEventsHome();
                    break;
                case 2:
                    RouterControl.jumpIpc();
                    break;
                case 3:
                    RouterControl.jumpPermissionHome();
                    break;
                case 4:
                    ContactsActivity.open(mContext);
                    break;
                case 5:
                    NotificationActivity.open(mContext);
                    break;
                case 6:
                    CameraAlbumActivity.open(mContext);
                    break;
                case 7:
                    MediaActivity.open(mContext);
                    break;
                case 8:
                    ServiceActivity.open(mContext);
                    break;
                case 9:
                    ConstraintLayoutActivity.open(mContext);
                    break;
                case 10:
                    HttpUrlConnectionActivity.open(mContext);
                    break;
                case 11:
                    OkHttpActivity.open(mContext);
                    break;
                case 12:
                    RouterControl.jumpMaterialToolbar();
                    break;
                case 13:
                    ViewModelActivity.open(mContext);
                    break;
                case 14:
                    WorkerActivity.open(mContext);
                    break;
            }
        });
        mBinding.rv.setLayoutManager(new LinearLayoutManager(this));
        mBinding.rv.setAdapter(adapter);
    }

}
